<html>
<head>
<title>Admin - Iron Puzzler {{ game.location }}</title>
<link rel="stylesheet" href="static/style.css">
</head><body><div class="pagecontent">

<h2 style="margin-bottom: 0">
<a href="/">IP {{ game.location }}</a> &raquo; Administration</h2>

<p style="margin-top: 0; text-indent: -25px">
<em>{{ admin_email }}</em>
(<a href="{{ admin_logout_url }}">sign out</a>).</p>

<form action="/admin" method="post">
<h3>Location:
<input type="text" name="location" value="{{ game.location }}"></h3>

<h3>Secret ingredients</h3>

<p>
1. <input type="text" name="ingredient0" value="{{ game.ingredients.0 }}"> 
2. <input type="text" name="ingredient1" value="{{ game.ingredients.1 }}"> 
3. <input type="text" name="ingredient2" value="{{ game.ingredients.2 }}"> 
<br>
<label>
  <input type="checkbox" name="ingredients_visible" value="true"
    {% if game.ingredients_visible %} checked {% endif %} >
  Make ingredients visible
</label>
</p>

<h3>Teams</h3>

{% if teams %}
<table>
  <tr>
    <td> </td>
    <td>Bonus</td>
    <td>Voted</td>
    {% for puzzle in puzzles %}
      <td align="center">
        <a href="/puzzle?t={{ puzzle.author_id }}&p={{ puzzle.number|urlencode }}" title="#{{ puzzle.number }} &quot;{{ puzzle.title }}&quot; ({{ puzzle.key_name }}) by {{ puzzle.author }}">#{{ puzzle.number }}</a>
      </td>
    {% endfor %}
  </tr>
  {% for team in teams|dictsort:"name" %}
    <tr>
      <td>
        <nobr><a href="/team?t={{ team.key_id }}">{{ team.name }}</a></nobr>
      </td>
      <td>
        <input type="text" size="3" name="bonus.{{ team.key_id }}"
               value="{{ team.bonus|default:0.0 }}">
      </td>
      <td align="center">
        {% if team.feedback_count %}
          {{ team.feedback_count }}
        {% else %}
          --
        {% endif %}
      </td>
      {% for work in team.works %}
        <td align="center">
          {% if work.puzzle.author_id == team.key_id %}
            <a href="/puzzle?t={{ team.key_id }}&p={{ work.puzzle.number|urlencode }}" 
               class="puzzle_author" title="{{ team.name }} wrote #{{ work.puzzle.number }} &quot;{{ work.puzzle.title }}&quot;">
              A
            </a>
          {% else %}
            {% if work.solve_rank %}
              <a href="/guess?t={{ team.key_id }}&p={{ work.puzzle.number|urlencode }}"
                 class="guess_correct"
                 title="{{ team.name }} solved #{{ work.puzzle.number }} &quot;{{ work.puzzle.title }}&quot; {{ work.solve_rank }}&#10;{{ work.solve_time|timesince }} ago ({{ work.guess_count }} attempt{{ work.guess_count|pluralize }})">
                {{ work.solve_rank }}
              </a>
            {% else %} {% if work.guess_count %}
              <a href="/guess?t={{ team.key_id }}&p={{ work.puzzle.number|urlencode }}"
                 class="guess_incorrect"
                 title="{{ team.name }} made {{ work.guess_count }} attempt{{ work.guess_count|pluralize }} for #{{ work.puzzle.number }} &quot;{{ work.puzzle.title }}&quot;">
                {{ work.guess_count }}x
              </a>
            {% else %}
              <a href="/guess?t={{ team.key_id }}&p={{ work.puzzle.number|urlencode }}"
                 class="guess_none">
                --
              </a>
            {% endif %} {% endif %}
          {% endif %}
        </td>
      {% endfor %}
    </tr>
  {% endfor %}
</table>
{% endif %} {# teams #}

<p>
  <label>Add team: <input type="text" name="new_team" size="25"></label>
  <label>pw: <input type="text" name="new_password" size="10"></label>
</p>

{% if teams %}
  <p>
    <label>Delete team: <input tyep="text" name="delete_team" size="25"></label>
    (Type the name to show you mean it!)
  </p>
{% endif %}

{% if puzzles %}
<h3>Puzzles</h3>

<table>
<tr>
  <td> </td>
  <td>Title</td>
  <td>Type</td>
  <td>Author</td>
  <td>Puz. file</td>
  <td>Sol. file</td>
  <td align="center">Sol. text</td>
  <td align="center">Ans.</td>
  <td align="center">Err.</td>
  <td align="center">Com.</td>
</tr>
{% for puzzle in puzzles %}
<input type="hidden" name="number.{{ puzzle.author_id }}.{{ puzzle.key_name }}.orig" value="{{ puzzle.number }}">
<tr>
  <td><nobr>#<input type="text" size="2" name="number.{{ puzzle.author_id }}.{{ puzzle.key_name }}" value="{{ puzzle.number }}"></nobr></td>
  <td><nobr><a href="/puzzle?t={{ puzzle.author_id }}&p={{ puzzle.number|urlencode }}">{{ puzzle.title }}</a></nobr></td>
  <td>{{ puzzle.key_name }}</td>
  <td><nobr><a href="/team?t={{ puzzle.author_id }}">{{ puzzle.author }}</a></nobr></td>
  <td>{% if puzzle.puzzle_blob %}
    <a href="/download?t={{ puzzle.author_id }}&p={{ puzzle.number|urlencode }}&f=p">{{ puzzle.puzzle_blob.filename|default:"file" }}</a>
  {% endif %}</td>
  <td>{% if puzzle.solution_blob %}
    <a href="/download?t={{ puzzle.author_id }}&p={{ puzzle.number|urlencode }}&f=s">{{ puzzle.solution_blob.filename|default:"file" }}</a>
  {% endif %}</td>
  <td align="center">{% if puzzle.solution %}Y{% endif %}</td>
  <td align="center">{% if puzzle.answers %}{{ puzzle.answers|length }}{% endif %}</td>
  <td align="center">{% if puzzle.errata %}Y{% endif %}</td>
  <td align="center">{% if puzzle.comment_count %}{{ puzzle.comment_count }}{% endif %}</td>
</tr>
{% endfor %}
</table>

<p>
  <label><input type="checkbox" name="assign_numbers" value="true">
  Assign grouped random numbers to numberless puzzles,</label>
  <label>starting at
  <input type="text" size="2" name="assign_start" value="1"></label><br>
</p>

{% endif %}

<h3>Game State</h3>

<p>

<label><input type="checkbox" name="login_enabled" value="true"
  {% if game.login_enabled %} checked {% endif %} >
Enable team logins
</label><br>
<label><input type="checkbox" name="solving_enabled" value="true"
  {% if game.solving_enabled %} checked {% endif %} >
Enable answer submission
</label><br>
<label><input type="checkbox" name="voting_enabled" value="true"
  {% if game.voting_enabled %} checked {% endif %} >
Enable voting on puzzles
</label><br>
<label><input type="checkbox" name="results_enabled" value="true"
  {% if game.results_enabled %} checked {% endif %} >
Publish final results
</label><br>

</p>

<h3>Access to this admin page</h3>

<textarea name="admin_users" cols="40" rows="5" class="leftside">
{{ game.admin_users|join:"&#10;" }}</textarea>

<p class="rightside">Google usernames (eg. <em>joe.smith@gmail.com</em>),
separated by lines or commas.</p>

<h3><button type="submit">Submit changes</button></h3>
</form>

</div></body></html>  <!-- end .pagecontent -->
